﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hack.Misc.BodyCalculations
{
    public static class HeartRate
    {
        public static TargetHeartRates TargetHartRate(int age)
        {
            return new TargetHeartRates(age);
        }
    }
    public class TargetHeartRates
    {
        private int _age;
        private int _rateMax;
        private int _rate90;
        private int _rate80;
        private int _rate70;
        private int _rate60;

        public int Age { get { return this._age; } set { recalculate(value); } }
        public int RateMax { get { return this._rateMax; } }
        public int Rate90Anaerobic { get { return this._rate90; } }
        public int Rate80IntervalTraining { get { return this._rate80; } }
        public int Rate70Aerobic { get { return this._rate70; } }
        public int Rate60Light { get { return this._rate60; } }

        public TargetHeartRates(int age)
        {
            recalculate(age);
        }

        private void recalculate(int age)
        {
            this._age = age;
            this._rateMax = (int)System.Math.Round(208 - (0.7 * age));
            this._rate90 = (int)System.Math.Round(_rateMax * 0.9);
            this._rate80 = (int)System.Math.Round(_rateMax * 0.8);
            this._rate70 = (int)System.Math.Round(_rateMax * 0.7);
            this._rate60 = (int)System.Math.Round(_rateMax * 0.6);
        }

        public static TargetHeartRates Calculate(int age)
        {
            return new TargetHeartRates(age);
        }
    }
}
